package com.guojiaming.shop.service;

import com.guojiaming.shop.bean.AfterSale;
import com.guojiaming.shop.bean.Sales;
import com.guojiaming.shop.dao.AfterSaleMapper;
import com.guojiaming.shop.dao.SalesMapper;
import com.guojiaming.shop.exception.DataModifyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author vivo
 */
@Service
@Transactional(rollbackFor = {Exception.class})
public class SaleService {
    @Resource
    AfterSaleMapper afterSaleMapper;
    @Resource
    SalesMapper salesMapper;


    public AfterSale after(AfterSale afterSale) {
        if (afterSaleMapper.saveAfterSale(afterSale) <= 0) {
            throw new DataModifyException();
        }
        return afterSale;
    }

    public Sales add(Sales sales) {
        salesMapper.saveSale(sales);
        return sales;
    }
}
